package com.eastfair.certificate.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.boot.request.PageParams;
import com.eastfair.boot.service.SuperCacheService;
import com.eastfair.boot.service.SuperService;
import com.eastfair.certificate.dto.CertificateOrderDTO;
import com.eastfair.certificate.dto.CertificateUserDTO;
import com.eastfair.certificate.dto.TakeApplyerDTO;
import com.eastfair.certificate.entity.CertificateOrder;
import com.eastfair.certificate.entity.CertificateUser;
import com.eastfair.certificate.vo.CertificateOrderVO;
import com.eastfair.core.base.R;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 业务接口
 * 制证订单
 * </p>
 *
 * @author ligang
 * @date 2022-08-02
 */
public interface CertificateOrderService extends SuperCacheService<CertificateOrder> {



    /**
     * 生成订单
     * @param certificateUserIdList 用户证件id集合
     * @return
     */
    CertificateOrderVO createOrder(List<Long> certificateUserIdList);

    /**
     * 删除订单关系
     * @param certificateUserIdList 用户证件id集合
     * @return
     */
    CertificateOrderVO removeOrder(List<Long> certificateUserIdList);
    /**
     * 校验证件
     * @param certificateUserIdList
     * @return
     */
    R verify(List<Long> certificateUserIdList);

    /**
     * 分页查询订单
     * @return
     */
    IPage<CertificateOrderVO> pageOrder(PageParams<CertificateOrderDTO> params);


    /**
     * 支付订单
     * @param certificateOrder 订单
     * @return
     */
    CertificateOrderVO payOrder(CertificateOrder certificateOrder);


    /**
     * 取消订单
     * @param orderId 订单id
     * @return
     */
    CertificateOrderVO cancelOrder(Long orderId);

    /**
     * 领取订单的证件
     * @param certificateOrderDTO 订单
     * @return
     */
    CertificateOrderVO drawOrder(CertificateOrderDTO certificateOrderDTO);

    /**
     * 预约领取订单的证件
     * @param certificateOrderDTO 订单
     * @return
     */
    CertificateOrderVO makeDrawOrder(CertificateOrderDTO certificateOrderDTO);



    /**
     * 订单开取发票
     * @param orderId 订单id
     * @return
     */
    CertificateOrderVO takeOrder(Long orderId);


    /**
     * 申请退款
     * @param certificateOrderDTO 订单id
     * @return
     */
    CertificateOrderVO executeReturnOrder(CertificateOrderDTO certificateOrderDTO);


    /**
     * 审核退款
     * @param orderId 订单id
     * @param isAuth 审核是否成功
     * @return
     */
    CertificateOrderVO authReturnOrder(Long orderId,Boolean isAuth);

    /**
     * 订单详情
     * @param orderId 订单id
     * @return
     */
    CertificateOrderVO detail(Long orderId);

    /**
     * do转vo
     *
     * @param model
     */
    CertificateOrderVO doToVo(CertificateOrder model);

    /**
     * do转vo
     *
     * @param modelList
     */
    List<CertificateOrderVO> doToVos(List<CertificateOrder> modelList);


    /**
     * 通用查询
     *
     * @param modelDTO DTO
     * @param ids      主键id集合
     * @return list
     */
    List<CertificateOrder> list(CertificateOrderDTO modelDTO, List<Long> ids);

    /**
     * 通用查询
     *
     * @param modelDTO DTO
     * @param ids      主键id集合
     * @return list
     */
    List<CertificateOrder> listOfCache(CertificateOrderDTO modelDTO, List<Long> ids);

    /**
     * 创建订单
     * @param certificateUserList
     */
    Boolean createOrderOfCertificate(List<CertificateUser> certificateUserList);
    /**
     * 补证
     * @return
     */
    Boolean makeCertificate(CertificateUserDTO certificateUserDTO);

    /**
     * 计算退款费用
     * @param id
     * @return
     */
    BigDecimal queryReturnMoney(Long id);


    /**
     * 计算发票费用
     * @param id
     * @return
     */
    BigDecimal queryTakeMoney(Long id);

    /**
     * 计算订单费用
     * @param id
     * @return
     */
    BigDecimal queryOrderMoney(Long id);


    /**
     * 开发票
     * @param takeApplyerDTO
     */
    Boolean takeRate(TakeApplyerDTO takeApplyerDTO);

}
